package com.xhdx.clone;

public class CloneTest {

    public static void main(String[] args) throws CloneNotSupportedException {
        School s1 = new School();
        s1.setSchoolName("实验小学");
        s1.setStuNums(100);
        Student stu1 = new Student();
        stu1.setAge(20);
        stu1.setName("zhangsan");
        stu1.setSex(new StringBuffer("男"));
        s1.setStu(stu1);
        System.out.println(
                "s1: " + s1 + " s1的hashcode:" + s1.hashCode() + "  s1中stu1的hashcode:" + s1.getStu().hashCode());
        School s2 = s1.clone(); // 调用重写的clone方法，clone出一个新的school---s2
        System.out
                .println("s2: " + s2 + " s2的hashcode:" + s2.hashCode() + " s2中stu1的hashcode:" + s2.getStu().hashCode());
        if(s1.equals(s2)){
            System.out
            .println("s1.equals(s2):true");
        }
        //引用
        School s3 = s1;
        if(s1.equals(s3)){
            System.out
            .println("s1.equals(s3):true");
        }
    }
}
